//
//  DutyHolidayTableViewCell.m
//  MobileOffice
//
//  Created by jjkj on 16/10/31.
//  Copyright © 2016年 liaoningjujin. All rights reserved.
//

#import "DutyHolidayTableViewCell.h"
#define COLOR_BUTTONGREEN [UIColor colorWithRed:39/255.0 green:143/255.0 blue:117/255.0 alpha:1]

@implementation DutyHolidayTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier row:(NSInteger)row model:(DutyDropListModel *)model viewWidth:(CGFloat)viewWidth{
    if (self=[super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        _dutyType=row;
        _dutyModel=model;
        self.width=viewWidth;
        self.userInteractionEnabled=YES;
        _headImageView=[MyControl creatImageViewWithFrame:CGRectMake(10, 10, 44, 44) imageName:nil];
        [self.contentView addSubview:_headImageView];
        
        _myTitle=[MyControl creatLabelWithFrame:CGRectMake(_headImageView.x+_headImageView.width+10, 20, 150, 20) text:@""];
        _myTitle.textColor=[UIColor blackColor];
        _myTitle.font=FONT_17;
        [self.contentView addSubview:_myTitle];
        
        _footView=[[UIView alloc]initWithFrame:CGRectMake(0, 64, self.width, 180)];
        _footView.backgroundColor=COLOR_BACKGROUND_GRAY;
        [self.contentView addSubview:_footView];
        
        //titleArr=@[@"调休",@"探亲假",@"工伤假",@"年假",@"产假",@"丧假",@"婚假",@"事假",@"病假"];
        CGFloat buttonWidth=(self.width-15*4)/3;
        for (int i=0; i<model.dataArr.count; i++) {
            DutyDropListModel *listModel=model.dataArr[i];
            UIButton *signButton=[MyControl creatButtonWithFrame:CGRectMake(15*(i%3+1)+buttonWidth*(i%3), 15*(i/3+1)+40*(i/3), buttonWidth, 40) target:self sel:@selector(dutyClick:) tag:row*1000+i image:nil title:listModel.keyword];
            signButton.backgroundColor=COLOR_BUTTONGREEN;
            [signButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            signButton.layer.masksToBounds=YES;
            signButton.layer.cornerRadius=5;
            [_footView addSubview:signButton];
        }
        
        _lineLabel=[[UILabel alloc]initWithFrame:CGRectMake(0, 63, self.width, 1)];
        _lineLabel.backgroundColor=BACKCOLOR_GRAY;
        [self.contentView addSubview:_lineLabel];
    }
    return self;
}


- (void)dutyClick:(UIButton *)button{
    DutyDropListModel *model=_dutyModel.dataArr[button.tag%1000];
    if (_myBlock) {
        _myBlock(_dutyType,button.tag%1000,model.keyword,model.BusinessCode);
    }
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
